import { pay, bankFullRefund  } from '@/uni_modules/oneoil-fuiou-pay'
export default{
	data(){
		return {
			
		}
	},
	
	computed: {
		sn() {
			return this.$store.state.sn
		}
	},
	methods:{
		
		payByCard(type,arg1){
			
			console.log(arg1)
			return new Promise(resolve=>{
				pay({
					transType: 21,
					amount: arg1.money*100+'',
					orderNumber: arg1.id+'',
					remark: '备注'
				},(data)=>{
				console.log(data)
				if(data.code===1){
					uni.api.posBankSelfPayCallback({
					  cardNo:data.data.cardNo ,
					  oldTrace: data.data.traceNo,
					  orderId: arg1.id,
					  orderType: type,
					  payStatus: "PAY"
					}).then(re=>{
						if(re.code==='200'){
							resolve(re.code)
						}
					})
				}else{
					uni.showToast({
						title: data.message, // 提示的内容
						icon: 'none',
					})
				}
				
				})
				
			})
		},
		payByCardRefund(type,arg){
			console.log(arg)
			
			return new Promise(resolve=>{
				bankFullRefund({
					oldTrace: arg.refundOrderNo+'', // 原交易凭证号
					amount:arg.money*100+'' , // 原交易凭证号
					isManagePwd: 'true', // 撤销时不显示输入主管密码(false-不显示输入密码，true-显示主管输入密码)
					orderNumber: arg.id+'', // 订单号（第三方自定义不能超过60个字节，支持中文、字母、数字）
					remark: '', // 备注
				},(data)=>{
				console.log(data)
				if(data.code===1){
					uni.api.posBankSelfPayCallback({
					  cardNo:arg.cardNo ,
					  oldTrace: arg.refundOrderNo,
					  orderId: arg.id,
					  orderType: type,
					  payStatus: "REFUND"
					}).then(re=>{
						if(re.code==='200'){
							resolve(re.code)
						}
					})
				}else{
					uni.showToast({
						title: data.message, // 提示的内容
						icon: 'none',
					})
				}
				
				})
			})
		}
	}
}